﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace WindowsFormsApplication1.wtyczki
{
    public static class Cut
    {
        public static Bitmap doCut(Bitmap bm)
        { 
            List<int> lst=new List<int>();
            //int xInt, yInt, xWidth, yHeight;
            using (CutForm form2 = new CutForm(bm))
            {
                form2.ShowDialog();
                lst= form2.TheValue;
            }
            Bitmap bmTmp =null;
            int xInit = lst[0];
            int yInit = lst[1];
            int xWidt = lst[2];
            int yHeiht = lst[3];
            if(xWidt>0 && yHeiht>0)
            bmTmp = new Bitmap(xWidt, yHeiht);
            else
                return null;
            for (int y = 1; y < yHeiht; y++)
            {
                for (int x = 1; x < xWidt; x++)
                {
                    bmTmp.SetPixel(x, y, bm.GetPixel(x + xInit, y + yInit)); 
                }
            }
            return bmTmp;


        }
    }
}
